def simple(n):
    d = 0
    for i in range(1, n + 1):
        if n % i == 0:
            d += 1
    if d == 2:
        return n;
    return 0;

digit = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
num = input().split()
flag = 0
if len(num) != 3:
    print("Wrong input")
else:
    if num[0] in digit:
        s = digit.index(num[0])
    if num[1] in digit:
        d = digit.index(num[1])
    if num[2] in digit:
        e = digit.index(num[2])
    n = s * 100 + d * 10 + e;
    print(simple(n))
